<template>
	<view>
		<!-- 头部导航 -->
		  <uni-nav-bar background-color="#3286ed" rightText="保存" @clickRight="addBtn" :statusBar="true" :fixed='true' color="#fff" title="新增租赁结算单"  left-icon="left"  @clickLeft="backFn" >
		   </uni-nav-bar>
		   <!-- 页面表格 -->
		   <view style="background-color: #fff;">
			   <u-cell title="订单编号" @click="popBtn" name="订单编号">
				   <template #value>
					   <view v-if="formData.orderNo">{{formData.orderNo}}</view>
					   <view v-else>请选择</view>
				   </template>
				   <template #label>
					   <view v-if="!formData.orderNo && ruleShow==true" style="color: red;font-size:12px;">请输入订单号</view>
				   </template>
			   </u-cell>
			   <u-cell title="合同模板">
				   <template #value>
					   <view v-if="formData.contractTemplate==1">租赁订单</view>
					   <view v-if="formData.contractTemplate==2">销售订单</view>
				   </template>
				   <template #label>
				   	 <view v-if="!formData.contractTemplate && ruleShow==true" style="color: red;font-size:12px;">请输入合同模板</view>
				   </template>
			   </u-cell>
			   <u-cell title="发起人">
				   <template #value>
					 <view>{{formData.sponsorName}}</view>
				   </template>
				   <template #label>
				   	 <view v-if="!formData.sponsorName && ruleShow==true" style="color: red;font-size:12px;">请输入发起人</view>
				   </template>
			   </u-cell>
			   <u-cell title="业务员">
				   <template #value>
					   <view>{{formData.salesmanName}}</view>
				   </template>
				   <template #label>
				   	 <view v-if="!formData.salesmanName && ruleShow==true" style="color: red;font-size:12px;">请输入业务员</view>
				   </template>
			   </u-cell>
			   <u-cell title="协同人">
				   <template #value>
					  <view>{{formData.collaboratorName}}</view>
				   </template>
			   </u-cell>
			   <u-cell title="签订人" >
				   <template #value>
					   <view>{{formData.signRenName}}</view>
				   </template>
			   </u-cell>
			   <u-cell title="信息提供人" >
				   <template #value>
					   <view>{{formData.signRenName}}</view>
				   </template>
			   </u-cell>
			   <u-cell title="申请日期">
				   <template #value>
					   <view>{{formData.applyDate}}</view>
				   </template>
			   </u-cell>
			   <u-cell title="结算单编号">
				   <template #value>
					   <view>{{formData.number}}</view>
				   </template>
			   </u-cell>
			   <u-cell title="客户名称">
				   <template #value>
					   <view>{{formData.customerName}}</view>
				   </template>
			   </u-cell>
			   <u-cell title="业务所属公司">
				   <template #value>
					   <view>{{businessCompany}}</view>
				   </template>
			   </u-cell>
			  <!-- <u-cell title="项目名称">
				   <template #value>
					   <view>{{formData.projectName}}</view>
				   </template>
			   </u-cell> -->
			   <u-cell title="项目地区域">
				   <template #value>
					   <view>{{projectArea}}</view>
				   </template>
			   </u-cell>
			   <u-cell title="日租金合计">
				   <template #value>
					   <view>{{formData.totalDailyRent}}</view>
				   </template>
			   </u-cell>
			   <u-cell title="应收租金">
				   <template #value>
					   <view>{{formData.rentReceivable}}</view>
				   </template>
			   </u-cell>
			  <u-cell title="租金折让"  name="租金折让">
				   <!-- <template #value>
				   @click="pupBtn"
					   <view>{{formData.rentAllowanceAmount}}</view>
				   </template> -->
				   <template #value>
				   		<!-- <view>{{formData.rentAllowanceAmount}}</view> -->
						 <u--input @blur="blurFn" @focus="focusFn" v-model="formData.rentAllowanceAmount" border="none" placeholder='请输入折让金额'></u--input>
				   </template>
			   </u-cell>
			   
			   <u-cell title="折让说明">
			   </u-cell>
			   <view style="width:100%;min-height: 100px;border: solid 1px #c3c3c3;">
				   <input v-model="formData.rentAllowanceDescription" type="text" />
			   </view>
			   <u-cell title="租赁费用">
				   <template #value>
					   <view>{{totalMachineExpense}}</view>
				   </template>
			   </u-cell>
			   <u-cell title="租赁机器费用"></u-cell>
			   <view>
				   <uni-table border stripe emptyText="暂无更多数据" >
				   	<!-- 表头行 -->
				   	<uni-tr>
				   		<uni-th align="center">序号</uni-th>
				   		<uni-th align="center">产品名称</uni-th>
				   		<uni-th align="center">型号</uni-th>
				   		<uni-th align="center">机器编号</uni-th>
				   		<uni-th align="center">出库时间</uni-th>
				   		<uni-th align="center">入库时间</uni-th>
				   		<uni-th align="center">总天数</uni-th>
				   		<uni-th align="center">日租金</uni-th>
				   		<uni-th align="center">金额</uni-th>
				   	</uni-tr>
				   	<!-- 表格数据行 -->
				   	<uni-tr v-for="(item,index) in machineExpenseList" :key="index">
				   		<uni-td align="center">{{index+1}}</uni-td>
				   		<uni-td align="center">{{item.product_name}}</uni-td>
				   		<uni-td align="center">{{item.model}}</uni-td>
						<uni-td align="center">{{item.machine_no}}</uni-td>
						<uni-td align="center">{{item.outtime}}</uni-td>
						<uni-td align="center">{{item.retime}}</uni-td>
						<uni-td align="center">{{item.all_time}}</uni-td>
				   		<uni-td align="center">{{item.dailyTotalRent}}</uni-td>
				   		<uni-td align="center">{{item.rent}}</uni-td>
				   	</uni-tr>
				   </uni-table>   
			   </view>
			   <u-cell title="对账单附件">
			   </u-cell>
			   <u-cell title="账户信息附件">
			   </u-cell>
			   <u-cell title="机器结算表">
			   </u-cell>
			   <view v-if="formData.statementExpensesList.length>0" style="background-color: #fff;">
			   							<view style="display: flex;justify-content: space-between;margin:10px;">
			   								<!-- <view style="width:20%;text-align:center;">整机品名</view> -->
			   								<view style="width:10%;text-align:center;">型号</view>
			   											<view style="width:40%;text-align:center;">起租时间</view>
			   											<view style="width:40%;text-align:center;">截止时间</view>
			   											<!-- <view style="width:20%;text-align:center;">使用天数</view> -->
			   								<view style="width:20%;text-align:center;">数量</view>
			   								<view style="width:20%;text-align:center;">日租金</view>
			   								<view style="width:20%;text-align:center;">操作</view>
			   							</view>
			   							<view v-for="(item,index) in formData.statementExpensesList" :key="index" style="display: flex;justify-content: space-between;margin:10px;">
			   								<!-- <view style="width:20%;text-align:center;">{{item.productName}}</view> -->
			   								<view style="width:10%;text-align:center;">{{item.model}}</view>
			   											<view style="width:80%;text-align:center;padding:1px;" @click="openDate(index,1)"><u--input    v-model="item.startDate" ></u--input></view>
			   											<view style="width:80%;text-align:center;padding:1px;"  @click="openDate(index,2)"><u--input    v-model="item.endDate" ></u--input></view>
			   											<!-- <view style="width:30%;text-align:center;padding:5px;"><u--input    v-model="item.days" ></u--input></view> -->
			   								<view style="width:30%;text-align:center;padding:1px;"><u--input    v-model="item.quantity" ></u--input></view>
			   								<view style="width:38%;text-align:center;padding:1px;"><u--input v-model="item.dailyRent"@blur="sumMoney(index)"></u--input></view>
			   								<view style="width:20%;text-align:center;" @click="removeProduct(index)">删除</view>
			   								
			   							</view>
			   						</view>
			  <!-- <u-upload
			   	:fileList="fileList3"
			   	name="3"
			   	multiple
			   	:maxCount="10"
			   	:previewFullImage="true"
			   ></u-upload> -->
			   
			   <u-cell title="收取客户其他费用"></u-cell>
			   <view>
				  <uni-table border stripe emptyText="暂无更多数据" >
						<!-- 表头行 -->
						<uni-tr>
							<uni-th align="center">序号</uni-th>
							<uni-th align="center">费用类别</uni-th>
							<uni-th align="center">单位</uni-th>
							<uni-th align="center">数量</uni-th>
							<uni-th align="center">类别总金额</uni-th>
							
						</uni-tr>
						<!-- 表格数据行 -->
						<uni-tr v-for="(item,index) in formData.otherExpensesList" :key="index">
							<uni-td align="center">{{index+1}}</uni-td>
							<uni-td align="center">
							  <span v-if="item.expenseCategory==1">物流费</span>
							  <span v-if="item.expenseCategory==2">维修费</span>
							  <span v-if="item.expenseCategory==0">其他</span>
							</uni-td>
							<uni-td align="center">
								<span v-if="item.unit==0">其他</span>
								<span v-if="item.unit==1">台</span>
							</uni-td>
							<uni-td align="center">{{item.quantity}}</uni-td>
							<uni-td align="center">{{item.totalAmount}}</uni-td>
						</uni-tr>
				  </uni-table>  
			   </view>
			   <u-cell title="其他费用总额">
				   <template #value>
					   <view>{{formData.totalOtherExpenses}}</view>
				   </template>
			   </u-cell>
			   <u-cell title="项目应扣费用对象">	</u-cell>
			   <view>
				   <uni-table border stripe emptyText="暂无更多数据" >
					<!-- 表头行 -->
					<uni-tr>
						<uni-th align="center">序号</uni-th>
						<uni-th align="center">费用类别</uni-th>
						<uni-th align="center">单位</uni-th>
						<uni-th align="center">金额</uni-th>
						<uni-th align="center">是否已支付</uni-th>
						<uni-th align="center">支付方</uni-th>
						
					</uni-tr>
					<!-- 表格数据行 -->
					<uni-tr v-for="(item,index) in formData.deductibleExpensesList" :key="index">
						<uni-td align="center">{{index+1}}</uni-td>
						<uni-td align="center">
						  <span v-if="item.expenseCategory==1">物流费</span>
						  <span v-if="item.expenseCategory==2">维修费</span>
						  <span v-if="item.expenseCategory==0">其他</span>
						</uni-td>
						<uni-td align="center">
							<span v-if="item.unit==0">其他</span>
							<span v-if="item.unit==1">台</span>
						</uni-td>
						<uni-td align="center">{{item.amount}}</uni-td>
						<uni-td align="center">{{item.hasPaid}}</uni-td>
						<uni-td align="center">{{item.payer}}</uni-td>
					</uni-tr>
				   </uni-table>   
			   </view>
			   <u-cell title="应扣费用总额">
					   <template #value>
						   <view>{{formData.totalDeductibleExpenses}}</view>
					   </template>
			   </u-cell>
			   <u-cell title="物流辅料费用" ></u-cell>
			   <view>
				   <uni-table border stripe emptyText="暂无更多数据" >
				   	<!-- 表头行 -->
				   	<uni-tr>
				   		<uni-th align="center">序号</uni-th>
				   		<uni-th align="center">费用类别</uni-th>
				   		<uni-th align="center">数量</uni-th>
				   		<uni-th align="center">金额</uni-th>
				   		<uni-th align="center">型号</uni-th>
				   		<uni-th align="center">日期</uni-th>
				   		<uni-th align="center">支付方</uni-th>
				   		<uni-th align="center">操作</uni-th>
				   	</uni-tr>
				   	<!-- 表格数据行 -->
				   	<uni-tr v-for="(item,index) in formData.logisticsExpensesList" :key="index">
				   		<uni-td align="center">{{index+1}}</uni-td>
				   		<uni-td align="center">
				   		  <span v-if="item.expenseCategory==1">物流费</span>
				   		  <span v-if="item.expenseCategory==2">维修费</span>
				   		  <span v-if="item.expenseCategory==0">其他</span>
				   		</uni-td>
				   		<uni-td align="center">{{item.quantity}}</uni-td>
						<uni-td align="center">{{item.amount}}</uni-td>
						<uni-td align="center">{{item.model}}</uni-td>
						<uni-td align="center">{{item.expenseDate}}</uni-td>
						<uni-td align="center">{{item.payer}}</uni-td>
				   		<uni-td align="center">删除</uni-td>
				   	</uni-tr>
				   </uni-table>  
			   </view>
			   <u-cell title="物流费用总额">
					   <template #value>
						   <view>{{formData.totalLogisticsExpenses}}</view>
					   </template>
			   </u-cell>
			   <u-cell title="维修配件费用对象"></u-cell>
			   <view>
				   <uni-table border stripe emptyText="暂无更多数据" >
					<!-- 表头行 -->
					<uni-tr>
						<uni-th align="center">序号</uni-th>
						<uni-th align="center">费用类别</uni-th>
						<uni-th align="center">单位</uni-th>
						<uni-th align="center">备注</uni-th>
						<uni-th align="center">金额</uni-th>
						<uni-th align="center">操作</uni-th>
						
					</uni-tr>
					<!-- 表格数据行 -->
					<uni-tr v-for="(item,index) in formData.maintenanceCostList" :key="index">
						<uni-td align="center">{{index+1}}</uni-td>
						<uni-td align="center">
						 <span v-if="item.expenseCategory==1">物流费</span>
						  <span v-if="item.expenseCategory==2">维修费</span>
						  <span v-if="item.expenseCategory==0">其他</span>
						</uni-td>
						<uni-td align="center">
							<span v-if="item.unit==0">其他</span>
							<span v-if="item.unit==1">台</span>
						</uni-td>
						<uni-td align="center">{{item.remark}}</uni-td>
						<uni-td align="center">{{item.totalAmount}}</uni-td>
						<uni-td align="center">删除</uni-td>
					</uni-tr>
				   </uni-table>  
			   </view>
			   <u-cell title="维修费用总额">
					   <template #value>
						   <view >{{formData.totalMaintenanceCost==0 ? '' : formData.totalMaintenanceCost}}</view>
					   </template>
			   </u-cell>
			   <u-cell title="实收租金" @click="pupBtn" name="实收租金">
				   <template #value>
					   <view>{{formData.rentPaid}}</view>
				   </template>
				   <template #label>
				   	 <view v-if="!formData.rentPaid && ruleShow==true" style="color: red;font-size:12px;">请输入实收租金</view>
				   </template>
			   </u-cell>
			   <u-cell title="实收押金" name="实收押金">
				   <template #value>
					   <view>{{formData.depositPaid}}</view>
				   </template>
				   <template #label>
				   	 <view v-if="!formData.depositPaid && ruleShow==true" style="color: red;font-size:12px;">请输入实收押金</view>
				   </template>
			   </u-cell>
			   <u-cell title="应退押金" name="应退押金">
			   				   <template #value>
			   					   <view>{{formData.refundableDeposit}}</view>
			   				   </template>
			   				   <!-- <template #label>
			   				   	 <view v-if="!formData.refundableDeposit && ruleShow==true" style="color: red;font-size:12px;">请输入实收押金</view>
			   				   </template> -->
			   </u-cell>
			   
			   <u-cell title="预估毛利润" @click="pupBtn" name="预估毛利润">
				   <template #value>
					   <view>{{formData.estimateProjectProfit}}</view>
				   </template>
				   <template #label>
				   	 <view v-if="!formData.estimateProjectProfit && ruleShow==true" style="color: red;font-size:12px;">请输入预估毛利润</view>
				   </template>
			   </u-cell>
			   
		   </view>
		   <!-- 右侧弹出框 -->
		   <u-popup :closeable="true" :show="show" mode="right"  :closeOnClickOverlay="true" @close="show=false" overlayStyle="margin-top:88rpx;" customStyle="margin-top:88rpx;min-width:300px;">
			   <view >
				   <u-cell>
					   <template #title>
						   <view>客户姓名</view>
					   </template>
					   <template #value>
					   		<view @click="searchCustomer">
								<span v-if="orderFormData.customerName">{{orderFormData.customerName}}</span>
								<span v-else style="font-size: 14px;">请选择</span>
								<uni-icons style="vertical-align: middle;" type="forward" color="#c3c3c3" size="24"></uni-icons>
							</view>
					   </template>
				   </u-cell>
				   <u-cell title="订单状态" @click="orderShow=true">
					   <template #value>
						   <view v-if="orderFormData.orderStatus==0">市场部待审批</view>
						   <view v-if="orderFormData.orderStatus==8">财务部待审批</view>
						   <view v-if="orderFormData.orderStatus==1">待发货</view>
						   <view v-if="orderFormData.orderStatus==7">发货中</view>
						   <view v-if="orderFormData.orderStatus==2">已出库</view>
						   <view v-if="orderFormData.orderStatus==9">申请中</view>
						   <view v-if="orderFormData.orderStatus==3">已申请</view>
						   <view v-if="orderFormData.orderStatus==10">入库中</view>
						   <view v-if="orderFormData.orderStatus==4">已入库</view>
						   <view v-if="orderFormData.orderStatus==5">已对账</view>
						   <view v-if="orderFormData.orderStatus==6">完毕</view>
						   <view v-if="!orderFormData.orderStatus">请选择</view>
						   <view><uni-icons type="forward" size="24"></uni-icons></view>
					   </template>
				   </u-cell>
				   <u-cell>
					   <template #value>
						   <view>
							  <u-button text="查询" @click="searchFn" type="success" size='mini'></u-button>
						   </view>
					   </template>
				   </u-cell>
				<scroll-view  :scroll-y="true" class="scroll-Y" @scrolltolower="scrolltolower" >
				  <view class="list" v-for="(item,index) in orderList">
					  <view>订单编号：{{item.orderNo}}</view>
					  <view>客户名称:{{item.customerName}}</view>
					  <view>业务员:{{item.salesmanName}}</view>
					  <view>创建时间:{{item.orderDate}}</view>
					  <view class="list-btn"><u-button text="选择" @click="checkedBtn(item)" type="success" size='mini'></u-button></view>
				  </view>
				  <view v-if="this.orderList.length==this.orderTotal  && this.orderList.length!==0">沒有更多了</view>
				  </scroll-view>
			   </view>
		   </u-popup>
		   <!-- 订单的状态 -->
		   <u-action-sheet :actions="list" title="订单状态" @select="selectFn" @close="orderShow=false" :show="orderShow"></u-action-sheet>
	       <!-- 起租日期 -->
		   <!-- <u-datetime-picker @close="startDateShow=false"  :show="startDateShow" mode="date" @confirm="confirmFn"></u-datetime-picker> -->
		   <!-- <u-datetime-picker @close="endDateShow=false"  :show="endDateShow" mode="date" @confirm="confirmBtn"></u-datetime-picker> -->
	       <!-- 租金的折让 -->
		   <u-popup mode="center" :show="inputShow">
			   <view class="popup-box">
			     <view class="title-top">{{name}}</view>
			      <u--input placeholder="请输入内容" fontSize="12px" :clearable="true" border="bottom" v-model="value" ></u--input>
			      <view class="box-bottom">
			   	  <view style="border-right:solid 2px #eee" @click="inputShow=false">取消</view>	
			   	  <view @click="BtnOk">确认</view>	
			      </view>
			   </view>
		   </u-popup>
		  
		   <!-- 选择 -->
		   <!-- <u-action-sheet :actions="expenseTypeOption" @close="expenseTypeShow=false" @select="selectBtn" title="费用类别" :show="expenseTypeShow"></u-action-sheet> -->
		   <!-- <u-action-sheet :actions="expenseUnitOption" @close="expenseUnitShow=false" @select="selectBtn2" title="费用类别单位" :show="expenseUnitShow"></u-action-sheet> -->
		   <!-- 是否已支付 -->
		   <!-- <u-action-sheet :actions="isPay" @close="payShow=false" @select="selectBtn3" title="是否已支付" :show="payShow"></u-action-sheet> -->
		   <!-- 型号 -->
		   	<!-- <u-picker :show="modelShow" @confirm="modelConfirm" :columns="modelOption"></u-picker> -->
	       <!-- 消息提示-->
		   <u-toast ref="uToast"></u-toast>
		   <!-- 提示框 -->
		   	<u-modal showConfirmButton showCancelButton @confirm="BtnModel" @cancel="BtnShow=false" :show="BtnShow" title="提示" content='是否确认提交'></u-modal>
	</view>
</template>

<script>
	import {provinceNameList} from '@/api/region/region.js'
	import {repairListApi } from '@/api/repair.js'
	import {getLogisticsListApi} from '@/api/logistics.js'
	import {getMachineListExpenseApi,getStatementListApi} from '@/api/accountStatement.js'
	import {addFinalStatementApi} from '@/api/finnalStatement.js'
	import {listProduct} from '@/api/product/product.js'
	import {listOrder} from '@/api/order/order.js'
	import {getDicts} from '@/api/dictionary/index.js'
	export default {
		data() {
			return {
				statementExpensesList:[],
				formData:{
				 contractTemplate:'',//	是	String	合同模板
				 sponsor:'',//	是	Long	发起人
				 sponsorName:'',//是	string	发起人名称
				 salesman:'',//	是	Long	业务员
				 salesmanName:'',//	是	string	业务员名称
				 informationProvider:'',//	是	Long	信息提供人
				 informationProviderName:'',//	是	string	信息提供人名称
				 applyDate:'',//	是	Date	申请日期
				 number:'',//	是	String	编号
				 customerId:'',//	是	Long	客户
				 customerName:'',//	是	String	客户名称
				 businessCompany:'',//	是	string	业务所属公司
				 orderId:'',//	是	Long	订单id
				 orderNo:'',//	是	string	订单编号
				 projectArea:'',//	是	string	项目地区域
				 startDate:'',	//是	Date	起租日期
				 endDate:'',//	是	Date	到租日期
				 usedDays:'',//	是	Long	使用天数
				 totalDailyRent:'',//	是	BigDecimal	日租金合计
				 rentReceivable:'',//	是	BigDecimal	应收租金
				 rentAllowanceAmount:'',//	是	BigDecimal	租金折让金额
				 rentAllowanceDescription:'',//	是	String	折让说明
				 relationApprovalForm:'',//	是	String	关联特殊事项审批单
				 totalOtherExpenses:'',//	是	BigDecimal	其他费用总额
				 rentPaid:'',//	是	BigDecimal	实收租金
				 depositPaid:'',//	是	BigDecimal	实收押金
				 refundableDeposit:'',//	是	BigDecimal	应退押金
				 accountStatementAttachments:'',//	是	String	对账单附件
				 accountNumber:'',//	是	String	帐户信息附件
				 totalDeductibleExpenses:'',//	是	BigDecimal	应扣费用总额
				 totalLogisticsExpenses:'',//	是	BigDecimal	物流费用总额
				 totalMaintenanceCost:'',//	是	BigDecimal	维修费用总额
				 estimateProjectProfit:'',//	是	BigDecimal	预估项目毛利
				 signRenId:'',//	是	Long	签订人id
				 signRenName:'',//	是	String	签订人名称
				 collaborator:'',//	是	Long	协同人id
				 collaboratorName:'',//	是	String	协同人名称
				 otherExpensesList:[],//	是	[]	收取客户其他费用
				 deductibleExpensesList:[],//	是	[]	项目应扣费用对象
				 logisticsExpensesList:[],//	是	[]	物流及辅料费用对象
				 maintenanceCostList:[],//
				 statementExpensesList:[],//
				 refundableDeposit:''
				},
				OldNumber:0,
				name:'',
				value:'',
				expensesForm:{
					expenseCategory:'',
					unit:'',
					// quantity:'',
					// totalAmount:'',
					hasPaid:'',
					expenseDate:'',
					model:'',
				},//费用表单
				show:false,
				orderShow:false,
				startDateShow:false,//起租日期
				endDateShow:false,//到租日期
				moneyShow:false,//费用添加
				inputShow:false,
				expenseTypeShow:false,
				expenseUnitShow:false,
				payShow:false,
				modelShow:false,
				ruleShow:false,
				fileList3: [{
							url: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
						}],
				list:[],//订单状态
				orderFormData:{
					pageSize: 10,
					pageNum: 1,
					customerId:'',
					customerName:'',
					orderStatus:5
				},
				orderTotal:'',
				orderList:[],
				type:1,//控制右边弹框的
				businessCompanyOptions:[],//业务公司
				businessCompany:'',//业务公司显示
				projectAreaOptions:[],//地区域来源
				projectArea:'',//显示地区域
				startDate:'',
				endDate:'',
				expenseTypeOption:[],//费用类别
				expenseUnitOption:[],//费用单位类别
				isPay:[],//是否支付
				modelOption:[],//型号集合
				totalMachineExpense:0,//总租金
				machineExpenseList:'',//机器的详情展示列表
				expenseType:'',//费用类别展示
				BtnShow:false
			};
		},
		onLoad() {
			this.formData.number=this.setOrderNo()
			this.getStatus()
			this.getBusinessCompany()
		    this.getprojectArea()
			this.getExpenseType()
			this.getExpenseUnit()
			this.getPay()
			this.getModel()
		},
		onBackPress(){
			this.getValue()
		},
		methods:{
			// 选择客户返回的数据
			getValue(list){
				console.log(list,'B页面传递的数据')
				this.orderFormData.customerId=list.id
				this.orderFormData.customerName=list.name
			},
			// 返回
			backFn(){
				 uni.navigateBack({delta:1})
			},
			// 提交
			async addBtn(){
				console.log();
				
				if( !this.formData.rentPaid || !this.formData.estimateProjectProfit  || !this.formData.orderNo 
				 || !this.formData.contractTemplate  ||!this.formData.salesmanName ||!this.formData.sponsorName){
					this.ruleShow=true
					return false
				}
				this.BtnShow=true
				
			},
			async BtnModel(){
				this.BtnShow=false
				const res=await addFinalStatementApi(this.formData)
				console.log(res);
				// if(){}
				this.OldNumber=0
				this.$refs.uToast.show({
				    type: 'success',
					message:'添加成功！',
					complete(){
						uni.redirectTo({
							url:"/pages/finnalStatement/finnalStatement"
						})
					}
				})
				
			},
			// 租赁订单状态
			getStatus(){
				let newArr=[]
				getDicts('order_type').then(response=>{
				   this.list=response.data.map(item=>{
						return {name:item.dictLabel,value:item.dictValue}
					})
				})
				
			},
			// 业务所属公司
			getBusinessCompany(){
				getDicts('biz_business_company').then(response=>{
					// console.log(response);
					this.businessCompanyOptions=response.data
				})
			},
			// 项目地区
			getprojectArea(){
				provinceNameList().then(response=>{
					// console.log(response);
					let newArr=[]
					newArr=response.rows.map((item,index)=>{
						return {name:item.label,value:item.value}
					})
					this.projectAreaOptions=newArr
					// console.log(this.projectAreaOptions);
				})
			},
			// 费用类别
			getExpenseType(){
				getDicts('expense_type').then(response=>{
					// expenseTypeOption
					this.expenseTypeOption=response.data.map(item=>{
						return {name:item.dictLabel,value:item.dictValue}
					})
				})
			},
			// 项目费用单位
			getExpenseUnit(){
				getDicts('expense_type_unit').then(response=>{
					this.expenseUnitOption=response.data.map(item=>{
						return {name:item.dictLabel,value:item.dictValue}
					})
				})
			},
			// 获取型号
			getModel(){
				let newArr=[]
				listProduct({pageNum:1,pageSum:1000}).then(response=>{
					console.log(response);
					response.rows.forEach((item)=>{
						item.models.forEach(value=>{
		                    newArr.push(value.model)
						})
					})
					this.modelOption.push(newArr)
				})
			},
			// 是否已支付
		    getPay(){
				getDicts('pay').then(response=>{
					this.isPay=response.data.map(item=>{
						return {name:item.dictLabel,value:item.dictValue}
					})
				})
			},
			// 选择跳转到客户页面选择
			searchCustomer(){
				uni.navigateTo({
					url:"/pages/dialog/customer"
				})
			},
			// // 点击获取日期
			// dateBtn(){
			// 	console.log('111');
			// 	console.log(this.$refs.date);
			// 	this.$refs.date.show()
			// },
			// changeFn(e){
			// 	console.log(e);
			// },
			// 型号选择
			modelConfirm(e){
				console.log(e);
				this.expensesForm.model=e.value[0]
				this.modelShow=false
			},
			
			// 生成对账单编号
			setOrderNo(){
			      var date = new Date();
			      var year = date.getFullYear();        //年 ,从 Date 对象以四位数字返回年份
			      var month = date.getMonth() + 1;      //月 ,从 Date 对象返回月份 (0 ~ 11) ,date.getMonth()比实际月份少 1 个月
			      var day = date.getDate();             //日 ,从 Date 对象返回一个月中的某一天 (1 ~ 31)
			      //修改月份格式
			      if (month >= 1 && month <= 9) {
			        month = "0" + month;
			      }
			      //修改日期格式
			      if (day >= 0 && day <= 9) {
			        day = "0" + day;
			      }
			
			      let round = Math.floor(Math.random() * (999 - 100)) + 100;
			      var currentFormatDate = `${year}${month}${day}`;
			      return "JS"+currentFormatDate+round;
			    },
			selectFn(e){
				console.log(e);
				this.orderFormData.orderStatus=e.value
			},
			// 获取租赁订单
			getOrderList(){
				listOrder(this.orderFormData).then(res=>{
					console.log(res);
					this.orderList=res.rows
					this.orderTotal=res.total
				})
			},
			scrolltolower(){
				
				if(this.orderList.length==this.orderTotal){
					this.orderFormData.pageNum=1
					return false
				}
				this.orderFormData.pageNum++
				this.SearchOrderNo()
			},
			
			searchFn(){
				this.getOrderList()
			},
			// 右侧弹出框
			popBtn(e){
					this.getOrderList()
					this.show=true
					},
					
			pupBtn(e){
				console.log(e);
				
				if(e.name=='租金折让'){
					this.name=e.name
					this.value=this.formData.rentAllowanceAmount
					
				}
				if(e.name=='实收押金'){
					this.name=e.name
					this.value=this.formData.depositPaid
				}
				if(e.name=='预估毛利润'){
					this.name=e.name
					this.value=this.formData.estimateProjectProfit
				}
				if(e.name=='实收租金'){
					this.name=e.name
					this.value=this.formData.rentPaid
				}
				this.inputShow=true
			},
			blurFn(){
				console.log('11');
				this.formData.rentReceivable=Number(this.formData.rentReceivable)+Number(this.OldNumber)-Number(this.formData.rentAllowanceAmount)
				
			},
			focusFn(){
				
              console.log(this.formData.rentAllowanceAmount)
	            this.OldNumber=this.formData.rentAllowanceAmount
			},
			// 弹出输入框确定按钮
			BtnOk(){
			
				// if(this.name=='租金折让'){
				// 	this.formData.rentAllowanceAmount=this.value
				// 	this.formData.rentReceivable=Number(this.formData.rentReceivable)-Number(this.formData.rentAllowanceAmount)
				// }
				if(this.name=='实收押金'){
					this.formData.depositPaid=this.value
				}
				if(this.name=='预估毛利润'){
					this.formData.estimateProjectProfit=this.value
				}
				if(this.name=='实收租金'){
				    this.formData.rentPaid=this.value
				}
				this.value=''
				this.inputShow=false
			},
			// 选中
			async checkedBtn(item){
				console.log(item);
				this.formData.contractTemplate=item.contractTemplate
				this.formData.sponsor=item.sponsor
				this.formData.sponsorName=item.sponsorName
				this.formData.signRenId=item.salesman
				this.formData.signRenName=item.salesmanName
				this.formData.salesman=item.salesman
				this.formData.salesmanName=item.salesmanName
				// this.formData.informationProvider
				// this.formData.informationProviderName
				this.formData.applyDate=item.createTime
				this.formData.customerId=item.customerId
				this.formData.customerName=item.customerName
				this.formData.businessCompany=item.businessCompany
				this.formData.orderId=item.id
				this.formData.orderNo=item.orderNo
				this.formData.projectArea=item.projectArea
				// this.formData.totalDailyRent=item.totalDailyRent
				// this.formData.rentReceivable=item.totalRant
				this.formData.collaborator=item.collaborator
				this.formData.collaboratorName=item.collaboratorName
				this.formData.depositPaid=item.depositReceivable
				this.projectArea=this.getValu2(this.projectAreaOptions,item.projectArea)
				this.businessCompany=this.getValue1(this.businessCompanyOptions,item.businessCompany)
				
				   // let response=await listOrder({orderNo:item.orderNo})//获取关租赁订单
				   // console.log(response);
				 let response=await getStatementListApi({orderNo:this.formData.orderNo})
				console.log(response);
				this.formData.statementExpensesList=response.rows[0].statementExpensesList
				this.formData.logisticsExpensesList=response.rows[0].logisticsExpensesList
				this.formData.otherExpensesList=response.rows[0].otherExpensesList
				this.formData.deductibleExpensesList=response.rows[0].deductibleExpensesList
				this.formData.maintenanceCostList=response.rows[0].maintenanceCostList
			    this.formData.totalDailyRent=response.rows[0].totalDailyRent
			    this.formData.rentReceivable=response.rows[0].rentReceivable
				this.formData.rentAllowanceAmount=response.rows[0].rentAllowanceAmount
			    this.formData.rentAllowanceDescription=response.rows[0].rentAllowanceDescription
			    this.formData.relationApprovalForm=response.rows[0].relationApprovalForm
			    this.formData.totalOtherExpenses=response.rows[0].totalOtherExpenses
			    this.formData.rentPaid=response.rows[0].rentPaid
			    this.formData.depositPaid=response.rows[0].depositPaid
			    this.formData.refundableDeposit=response.rows[0].refundableDeposit
				this.formData.accountStatementAttachments=response.rows[0].accountStatementAttachments
				this.formData.accountNumber=response.rows[0].accountNumber
				this.formData.totalDeductibleExpenses=response.rows[0].totalDeductibleExpenses
				this.formData.totalLogisticsExpenses=response.rows[0].totalLogisticsExpenses
				this.formData.totalMaintenanceCost=response.rows[0].totalMaintenanceCost
				this.formData.estimateProjectProfit=response.rows[0].estimateProjectProfit
				// 获取机器费用
				const res=await getMachineListExpenseApi({orderId:this.formData.orderId})
					res.rows.forEach((item,index)=>{
						  item.outtime=this.formatDate(item.outtime)
						  item.retime=this.formatDate(item.retime)
						  this.totalMachineExpense=this.totalMachineExpense+Number(item.rent)
						 
					})
					this.machineExpenseList=res.rows
					
			
				this.show=false
			},
			
			getValue1(arr,item){
				for(var i=0;i<arr.length;i++){
					if(item==arr[i].dictValue){
						return arr[i].dictLabel
					}
				}
			},
			// 操作菜单
			getValu2(arr,item){
				for(var i=0;i<arr.length;i++){
					if(item==arr[i].value){
						return arr[i].name
					}
				}
			},
		
			
			setTime(date){
				   var date = new Date(date);
				   var YY = date.getFullYear() + '-';
				   var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				   var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
				  return YY + MM + DD 
			},
			
			//格式转换
			    formatDate (d) {
			      var date = new Date(d);
			      var YY = date.getFullYear() + '-';
			      var MM =
			        (date.getMonth() + 1 < 10
			          ? '0' + (date.getMonth() + 1)
			          : date.getMonth() + 1) + '-';
			      var DD = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
			
			      return YY + MM + DD
			    },
			
		
		
		
		
		}
	}
</script>

<style lang="scss">
	.popup-box{
		min-width: 250px;
		min-height: 100px;
		text-align: center;
		
		.title-top{
			height:40px;
			line-height: 40px;
			font-size: 16px;
			font-weight: 600;
		}
		.box-bottom{
			display: flex;
			justify-content: space-around;
			height:40px;
			line-height: 40px;
			view{
				width:50%;
			}
		}
	}
	.list{
		position: relative;
		padding: 10px;
		border: solid 1px #c3c3c3;
		font-size: 12px;
		.list-btn{
			position: absolute;
			right:20px;
			bottom: 10px;
		}
	}
    .Box{
		.little-box{
			padding: 10px;
			border-bottom: solid 1px #c3c3c3;
			.title{
				font-size: 16px;
				margin-bottom: 5px;
			}
		}
		
	}
	.btn{
		width: 100%;
		min-height: 40px;
		line-height:40px;
		// margin-top: 25px;
		border: solid 1px #c3c3c3;
		display: flex;
		justify-content: space-evenly;
	}
</style>
